﻿using System.Collections;
using FlowCanvas;
using FlowCanvas.Nodes;
using ParadoxNotion.Design;

namespace Yoozoo.Gameplay.Liberty.Nodes
{
    [Category("Ggame")]
    public class IndustryUnlock : LatentActionNodeBase
    {
        public override bool allowRoutineQueueing
        {
            get { return false; }
        }

        private const string INDUSTRY_PANEL_NAME = "IndustryUnlockUI";

        public IEnumerator Invoke(int indID)
        {
            BlueprintUtils.OpenCloseUI(true, INDUSTRY_PANEL_NAME, indID.ToString(), "");
            yield return new UnityEngine.WaitUntil(() => BlueprintUtils.UIIsShowing(INDUSTRY_PANEL_NAME));
        }

        protected override void OnRegisterDerivedPorts(FlowNode node)
        {
            var p1 = node.AddValueInput<int>(parameters[0].Name);
            node.AddFlowInput("In", (f) => { Begin(Invoke(p1.value), f); });
        }
    }
}